import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';

class AppLocalizations {
  final Locale locale;

  AppLocalizations(this.locale);

  static AppLocalizations of(BuildContext context) {
    return Localizations.of<AppLocalizations>(context, AppLocalizations)!;
  }

  static const LocalizationsDelegate<AppLocalizations> delegate =
      _AppLocalizationsDelegate();

  static const List<LocalizationsDelegate> localizationsDelegates = [
    delegate,
    GlobalMaterialLocalizations.delegate,
    GlobalWidgetsLocalizations.delegate,
    GlobalCupertinoLocalizations.delegate,
  ];

  static const List<Locale> supportedLocales = [
    Locale('en', ''),
    Locale('zh', ''),
  ];

  // English translations
  String get appTitle => _localizedValues[locale.languageCode]!['appTitle']!;
  String get balance => _localizedValues[locale.languageCode]!['balance']!;
  String get btcPrice => _localizedValues[locale.languageCode]!['btcPrice']!;
  String get miningStatus =>
      _localizedValues[locale.languageCode]!['miningStatus']!;
  String get watchAds => _localizedValues[locale.languageCode]!['watchAds']!;
  String get basic => _localizedValues[locale.languageCode]!['basic']!;
  String get moderate => _localizedValues[locale.languageCode]!['moderate']!;
  String get advanced => _localizedValues[locale.languageCode]!['advanced']!;
  String get topTier => _localizedValues[locale.languageCode]!['topTier']!;
  String get plan1Price =>
      _localizedValues[locale.languageCode]!['plan1Price']!;
  String get plan2Price =>
      _localizedValues[locale.languageCode]!['plan2Price']!;
  String get plan3Price =>
      _localizedValues[locale.languageCode]!['plan3Price']!;
  String get planDetails =>
      _localizedValues[locale.languageCode]!['planDetails']!;
  String get beginnerMining =>
      _localizedValues[locale.languageCode]!['beginnerMining']!;
  String get subscribe => _localizedValues[locale.languageCode]!['subscribe']!;
  String get home => _localizedValues[locale.languageCode]!['home']!;
  String get contract => _localizedValues[locale.languageCode]!['contract']!;
  String get fission => _localizedValues[locale.languageCode]!['fission']!;
  String get wallet => _localizedValues[locale.languageCode]!['wallet']!;
  String get settings => _localizedValues[locale.languageCode]!['settings']!;
  String get signInToReceiveRewards =>
      _localizedValues[locale.languageCode]!['signInToReceiveRewards']!;
  String get increaseRewardsAndGiftsEveryDay =>
      _localizedValues[locale
          .languageCode]!['increaseRewardsAndGiftsEveryDay']!;
  String get day => _localizedValues[locale.languageCode]!['day']!;
  String get hours => _localizedValues[locale.languageCode]!['hours']!;
  String get total => _localizedValues[locale.languageCode]!['total']!;
  String get sorting => _localizedValues[locale.languageCode]!['sorting']!;
  String get vipContract =>
      _localizedValues[locale.languageCode]!['vipContract']!;
  String get signInContract =>
      _localizedValues[locale.languageCode]!['signInContract']!;
  String get advertisingContract =>
      _localizedValues[locale.languageCode]!['advertisingContract']!;
  String get active => _localizedValues[locale.languageCode]!['active']!;
  String get expired => _localizedValues[locale.languageCode]!['expired']!;
  String get itWillExpireIn =>
      _localizedValues[locale.languageCode]!['itWillExpireIn']!;
  String get advertisingSpace =>
      _localizedValues[locale.languageCode]!['advertisingSpace']!;
  String get fissionEarnings =>
      _localizedValues[locale.languageCode]!['fissionEarnings']!;
  String get withdraw => _localizedValues[locale.languageCode]!['withdraw']!;
  String get invitationLink =>
      _localizedValues[locale.languageCode]!['invitationLink']!;
  String get invitationCode =>
      _localizedValues[locale.languageCode]!['invitationCode']!;
  String get copy => _localizedValues[locale.languageCode]!['copy']!;
  String get inviteRewardMessage =>
      _localizedValues[locale.languageCode]!['inviteRewardMessage']!;
  String get inviteNow => _localizedValues[locale.languageCode]!['inviteNow']!;
  String get invitationHistory =>
      _localizedValues[locale.languageCode]!['invitationHistory']!;
  String get myCommission =>
      _localizedValues[locale.languageCode]!['myCommission']!;
  String get withdrawBitcoin =>
      _localizedValues[locale.languageCode]!['withdrawBitcoin']!;
  String get withdrawBitcoinToAccount =>
      _localizedValues[locale.languageCode]!['withdrawBitcoinToAccount']!;
  String get clickForGuide =>
      _localizedValues[locale.languageCode]!['clickForGuide']!;
  String get minimumWithdrawalAmount =>
      _localizedValues[locale.languageCode]!['minimumWithdrawalAmount']!;
  String get maximumWithdrawalAmount =>
      _localizedValues[locale.languageCode]!['maximumWithdrawalAmount']!;
  String get withdrawalFee =>
      _localizedValues[locale.languageCode]!['withdrawalFee']!;
  String get withdrawalAddress =>
      _localizedValues[locale.languageCode]!['withdrawalAddress']!;
  String get fillWithdrawalAddress =>
      _localizedValues[locale.languageCode]!['fillWithdrawalAddress']!;
  String get withdrawalAmount =>
      _localizedValues[locale.languageCode]!['withdrawalAmount']!;
  String get enterWithdrawalAmount =>
      _localizedValues[locale.languageCode]!['enterWithdrawalAmount']!;
  String get currentBalance =>
      _localizedValues[locale.languageCode]!['currentBalance']!;
  String get all => _localizedValues[locale.languageCode]!['all']!;
  String get login => _localizedValues[locale.languageCode]!['login']!;
  String get signUp => _localizedValues[locale.languageCode]!['signUp']!;
  String get vipUpgrade =>
      _localizedValues[locale.languageCode]!['vipUpgrade']!;
  String get improveMiningSpeed =>
      _localizedValues[locale.languageCode]!['improveMiningSpeed']!;
  String get upgrade => _localizedValues[locale.languageCode]!['upgrade']!;
  String get physicalMachineRoom =>
      _localizedValues[locale.languageCode]!['physicalMachineRoom']!;
  String get vipUpgradeMenu =>
      _localizedValues[locale.languageCode]!['vipUpgradeMenu']!;
  String get frequentlyAskedQuestions =>
      _localizedValues[locale.languageCode]!['frequentlyAskedQuestions']!;
  String get rating => _localizedValues[locale.languageCode]!['rating']!;
  String get comment => _localizedValues[locale.languageCode]!['comment']!;
  String get customerService =>
      _localizedValues[locale.languageCode]!['customerService']!;
  String get privacyWebsite =>
      _localizedValues[locale.languageCode]!['privacyWebsite']!;
  String get termsOfService =>
      _localizedValues[locale.languageCode]!['termsOfService']!;
  String get balanceLabel =>
      _localizedValues[locale.languageCode]!['balanceLabel']!;
  String get withdrawButton =>
      _localizedValues[locale.languageCode]!['withdrawButton']!;
  String get btcUsd => _localizedValues[locale.languageCode]!['btcUsd']!;
  String get withdrawalHistory =>
      _localizedValues[locale.languageCode]!['withdrawalHistory']!;
  String get withdrawing =>
      _localizedValues[locale.languageCode]!['withdrawing']!;
  String get paid => _localizedValues[locale.languageCode]!['paid']!;
  String get welcomeToLogin =>
      _localizedValues[locale.languageCode]!['welcomeToLogin']!;
  String get useApple => _localizedValues[locale.languageCode]!['useApple']!;
  String get google => _localizedValues[locale.languageCode]!['google']!;
  String get loggingIn => _localizedValues[locale.languageCode]!['loggingIn']!;
  String get loginSuccess =>
      _localizedValues[locale.languageCode]!['loginSuccess']!;
  String get welcomeBack =>
      _localizedValues[locale.languageCode]!['welcomeBack']!;
  String get loggedOut => _localizedValues[locale.languageCode]!['loggedOut']!;
  String get thankYou => _localizedValues[locale.languageCode]!['thankYou']!;
  String get membershipSubscription =>
      _localizedValues[locale.languageCode]!['membershipSubscription']!;
  String get restorePurchases =>
      _localizedValues[locale.languageCode]!['restorePurchases']!;
  String get renewalInstructions =>
      _localizedValues[locale.languageCode]!['renewalInstructions']!;
  String get paymentPolicy =>
      _localizedValues[locale.languageCode]!['paymentPolicy']!;
  String get renewalPolicy =>
      _localizedValues[locale.languageCode]!['renewalPolicy']!;
  String get cancellationPolicy =>
      _localizedValues[locale.languageCode]!['cancellationPolicy']!;
  String get userAgreement =>
      _localizedValues[locale.languageCode]!['userAgreement']!;
  String get privacyPolicy =>
      _localizedValues[locale.languageCode]!['privacyPolicy']!;
  String get membershipBeginnerMining =>
      _localizedValues[locale.languageCode]!['membershipBeginnerMining']!;
  String get membershipSubscribe =>
      _localizedValues[locale.languageCode]!['membershipSubscribe']!;
  String get privacyAgreement =>
      _localizedValues[locale.languageCode]!['privacyAgreement']!;
  String get privacyAgreementContent =>
      _localizedValues[locale.languageCode]!['privacyAgreementContent']!;
  String get agreeAndContinue =>
      _localizedValues[locale.languageCode]!['agreeAndContinue']!;
  String get disagree => _localizedValues[locale.languageCode]!['disagree']!;
  String get privacyPolicyText =>
      _localizedValues[locale.languageCode]!['privacyPolicyText']!;
  String get termsOfServiceText =>
      _localizedValues[locale.languageCode]!['termsOfServiceText']!;
  String get mustAgreeToContinue =>
      _localizedValues[locale.languageCode]!['mustAgreeToContinue']!;
  String get personalInformation =>
      _localizedValues[locale.languageCode]!['personalInformation']!;
  String get googleAccount =>
      _localizedValues[locale.languageCode]!['googleAccount']!;
  String get appleAccount =>
      _localizedValues[locale.languageCode]!['appleAccount']!;
  String get tapToConnect =>
      _localizedValues[locale.languageCode]!['tapToConnect']!;
  String get unbindAccount =>
      _localizedValues[locale.languageCode]!['unbindAccount']!;
  String get unbindConfirmMessage =>
      _localizedValues[locale.languageCode]!['unbindConfirmMessage']!;
  String get unbindSuccess =>
      _localizedValues[locale.languageCode]!['unbindSuccess']!;
  String get cancel => _localizedValues[locale.languageCode]!['cancel']!;
  String get unbind => _localizedValues[locale.languageCode]!['unbind']!;
  String get contractGuideTitle =>
      _localizedValues[locale.languageCode]!['contractGuideTitle']!;
  String get contractGuideP1 =>
      _localizedValues[locale.languageCode]!['contractGuideP1']!;
  String get contractGuideP2 =>
      _localizedValues[locale.languageCode]!['contractGuideP2']!;
  String get contractGuideP3 =>
      _localizedValues[locale.languageCode]!['contractGuideP3']!;
  String get contractGuideP4 =>
      _localizedValues[locale.languageCode]!['contractGuideP4']!;
  String get learnMore => _localizedValues[locale.languageCode]!['learnMore']!;
  String get enterInvitationCode =>
      _localizedValues[locale.languageCode]!['enterInvitationCode']!;
  String get enterInvitationCodePlaceholder =>
      _localizedValues[locale.languageCode]!['enterInvitationCodePlaceholder']!;
  String get paste => _localizedValues[locale.languageCode]!['paste']!;
  String get miningSpeedRewards =>
      _localizedValues[locale.languageCode]!['miningSpeedRewards']!;
  String get confirm => _localizedValues[locale.languageCode]!['confirm']!;

  static final Map<String, Map<String, String>> _localizedValues = {
    'en': {
      'appTitle': 'Bitcoin Mine',
      'balance': '0.0000000017739520',
      'btcPrice': '1BTC = \$108804',
      'miningStatus': '24 hours 3.40 Gh/s',
      'watchAds': 'Watch ads',
      'basic': 'BASIC',
      'moderate': 'MODERATE',
      'advanced': 'ADVANCED',
      'topTier': 'TOP-TIER',
      'plan1Price': '\$19.99/moon',
      'plan2Price': '\$54.99/3 moons',
      'plan3Price': '\$100.99/year',
      'planDetails': '274.25 Gh/s + Continuous improvement Mining speed',
      'home': 'Home',
      'contract': 'Contract',
      'fission': 'Fission',
      'wallet': 'Wallet',
      'settings': 'Settings',
      'signInToReceiveRewards': 'SIGN IN TO RECEIVE REWARDS',
      'increaseRewardsAndGiftsEveryDay': 'INCREASE REWARDS AND GIFTS EVERY DAY',
      'day': 'DAY',
      'hours': 'hours',
      'total': 'Total',
      'sorting': 'SORTING',
      'vipContract': 'VIP CONTRACT',
      'signInContract': 'SIGN IN CONTRACT',
      'advertisingContract': 'ADVERTISING CONTRACT',
      'active': 'ACTIVE',
      'expired': 'EXPIRED',
      'itWillExpireIn': 'It will expire in',
      'advertisingSpace': 'Advertising space',
      'fissionEarnings': 'Fission\nEarnings:',
      'withdraw': 'WITHDRAW',
      'invitationLink': 'INVITATION LINK:',
      'invitationCode': 'INVITATION CODE:',
      'copy': 'COPY',
      'inviteRewardMessage':
          'FOR EACH FRIEND YOU INVITE, YOU WILL RECEIVE AN ADDITIONAL 10% REWARD.',
      'inviteNow': 'INVITE NOW',
      'invitationHistory': 'Invitation History',
      'myCommission': 'My Commission',
      'withdrawBitcoin': 'Withdraw Bitcoin',
      'withdrawBitcoinToAccount': 'Withdraw Bitcoin to your account',
      'clickForGuide': '(Click for guide)',
      'minimumWithdrawalAmount': 'Minimum Withdrawal Amount:',
      'maximumWithdrawalAmount': 'Maximum Withdrawal Amount:',
      'withdrawalFee': 'Withdrawal Fee:',
      'withdrawalAddress': 'Withdrawal Address:',
      'fillWithdrawalAddress': 'Fill in the withdrawal address',
      'withdrawalAmount': 'Withdrawal Amount:',
      'enterWithdrawalAmount': 'Enter the withdrawal amount',
      'currentBalance': 'Current Balance:',
      'all': 'ALL',
      'login': 'Login',
      'signUp': 'Sign Up',
      'vipUpgrade': 'VIP UPGRADE',
      'improveMiningSpeed': 'Improve mining speed',
      'upgrade': 'UPGRADE',
      'physicalMachineRoom': 'Physical machine room',
      'vipUpgradeMenu': 'VIP upgrade',
      'frequentlyAskedQuestions': 'Frequently Asked Questions',
      'rating': 'Rate us',
      'comment': 'Comment',
      'customerService': 'Customer service',
      'privacyWebsite': 'Privacy website',
      'termsOfService': 'Terms of Service',
      'balanceLabel': 'BALANCE',
      'withdrawButton': 'Withdraw',
      'btcUsd': 'BTC / USD',
      'withdrawalHistory': 'Withdrawal History',
      'withdrawing': 'WITHDRAWING',
      'paid': 'PAID',
      'welcomeToLogin': 'Welcome to log in !',
      'useApple': 'Use Apple',
      'google': 'Google',
      'loggingIn': 'Logging in...',
      'loginSuccess': 'Login successful',
      'welcomeBack': 'Welcome back!',
      'loggedOut': 'Logged out',
      'thankYou': 'Thank you for using!',
      'membershipSubscription': 'Membership Subscription',
      'restorePurchases': 'RESTORE PURCHASES',
      'renewalInstructions': 'Renewal Instructions',
      'paymentPolicy':
          'Payment will be charged to iTunes Account at confirmation of purchase',
      'renewalPolicy':
          'Subscription automatically renews unless auto-renew is turned off at least 24-hours before the end of the current period',
      'cancellationPolicy':
          'Account will be charged for renewal within 24-hours prior to the end of the current period, and identify the cost of the renewal',
      'userAgreement': 'User Agreement',
      'privacyPolicy': 'Privacy Policy',
      'membershipBeginnerMining': 'BEGINNER MINING',
      'membershipSubscribe': 'SUBSCRIBE',
      'beginnerMining': 'BEGINNER MINING',
      'subscribe': 'SUBSCRIBE',
      'privacyAgreement': 'Privacy Agreement',
      'privacyAgreementContent':
          'We respect and protect your privacy. By using our services, you agree to our privacy policy and terms of service. We will collect and use your information in accordance with applicable laws and regulations to provide you with better services.',
      'agreeAndContinue': 'Agree and Continue',
      'disagree': 'Disagree',
      'privacyPolicyText': 'Privacy Policy',
      'termsOfServiceText': 'Terms of Service',
      'mustAgreeToContinue':
          'You must agree to the privacy policy to continue using the app',
      'personalInformation': 'Personal Information',
      'googleAccount': 'Google',
      'appleAccount': 'Apple',
      'tapToConnect': 'Tap to connect',
      'unbindAccount': 'Unbind Account',
      'unbindConfirmMessage': 'Are you sure you want to unbind your account?',
      'unbindSuccess': 'Account unbound successfully',
      'cancel': 'Cancel',
      'unbind': 'Unbind',
      'contractGuideTitle': 'BITCOIN MINING CONTRACT',
      'contractGuideP1':
          'When choosing a mining contract, hash rate is the key indicator. Displayed in the bottom right corner (e.g., "2Gh/s"), a higher hash rate means faster Bitcoin mining. Thus, boosting hash rate is the top goal for growing mining profits.',
      'contractGuideP2':
          'Paid contracts include a "Continuity Multiplier" — an extra reward for loyal users, stacked on regular earnings. The longer your paid contract stays active, the higher the multiplier. For instance, a 2x multiplier doubles your earnings from that contract.',
      'contractGuideP3':
          'Note that your final earnings depend on your hash rate share in the Bitcoin network, which fluctuates with the total number of miners. Daily earnings may vary by ±10%, but long-term earnings tend to stabilize at an average.',
      'contractGuideP4':
          'A longer mining cycle brings greater room for overall earnings growth.',
      'learnMore': 'Learn more',
      'enterInvitationCode': 'Enter the invitation code',
      'enterInvitationCodePlaceholder': 'ENTER THE INVITATION CODE',
      'paste': 'PASTE',
      'miningSpeedRewards': 'Mining speed rewards',
      'confirm': 'CONFIRM',
    },
    'zh': {
      'appTitle': '比特币挖矿',
      'balance': '0.0000000017739520',
      'btcPrice': '1BTC = \$108804',
      'miningStatus': '24小时 3.40 Gh/s',
      'watchAds': '观看广告',
      'basic': '基础版',
      'moderate': '标准版',
      'advanced': '高级版',
      'topTier': '顶级版',
      'plan1Price': '\$19.99/月',
      'plan2Price': '\$54.99/3个月',
      'plan3Price': '\$100.99/年',
      'planDetails': '274.25 Gh/s + 持续改进挖矿速度',
      'subscribe': '订阅',
      'home': '首页',
      'contract': '合约',
      'fission': '裂变',
      'wallet': '钱包',
      'settings': '设置',
      'signInToReceiveRewards': '签到领取奖励',
      'increaseRewardsAndGiftsEveryDay': '每日增加奖励和礼品',
      'day': '第',
      'hours': '小时',
      'total': '总计',
      'sorting': '排序',
      'vipContract': 'VIP合约',
      'signInContract': '签到合约',
      'advertisingContract': '广告合约',
      'active': '激活',
      'expired': '已过期',
      'itWillExpireIn': '将在',
      'advertisingSpace': '广告空间',
      'fissionEarnings': '裂变\n收益:',
      'withdraw': '提现',
      'invitationLink': '邀请链接:',
      'invitationCode': '邀请码:',
      'copy': '复制',
      'inviteRewardMessage': '每邀请一个朋友，您将获得额外10%的奖励。',
      'inviteNow': '立即邀请',
      'invitationHistory': '邀请历史',
      'myCommission': '我的佣金',
      'withdrawBitcoin': '提现比特币',
      'withdrawBitcoinToAccount': '将比特币提现到您的账户',
      'clickForGuide': '(点击查看指南)',
      'minimumWithdrawalAmount': '最小提现金额:',
      'maximumWithdrawalAmount': '最大提现金额:',
      'withdrawalFee': '提现手续费:',
      'withdrawalAddress': '提现地址:',
      'fillWithdrawalAddress': '填写提现地址',
      'withdrawalAmount': '提现金额:',
      'enterWithdrawalAmount': '输入提现金额',
      'currentBalance': '当前余额:',
      'all': '全部',
      'login': '登录',
      'signUp': '注册',
      'vipUpgrade': 'VIP升级',
      'improveMiningSpeed': '提升挖矿速度',
      'upgrade': '升级',
      'physicalMachineRoom': '物理机房',
      'vipUpgradeMenu': 'VIP升级',
      'frequentlyAskedQuestions': '常见问题',
      'rating': '评分',
      'comment': '评论',
      'customerService': '客服',
      'privacyWebsite': '隐私网站',
      'termsOfService': '服务条款',
      'balanceLabel': '余额',
      'withdrawButton': '提现',
      'btcUsd': 'BTC / USD',
      'withdrawalHistory': '提现历史',
      'withdrawing': '提现中',
      'paid': '已支付',
      'welcomeToLogin': '欢迎登录！',
      'useApple': '使用苹果',
      'google': '谷歌',
      'loggingIn': '登录中...',
      'loginSuccess': '登录成功',
      'welcomeBack': '欢迎回来！',
      'loggedOut': '已登出',
      'thankYou': '感谢使用！',
      'membershipSubscription': '会员订阅',
      'restorePurchases': '恢复购买',
      'renewalInstructions': '续费说明',
      'paymentPolicy': '购买确认时，费用将计入iTunes账户',
      'renewalPolicy': '除非在当前期间结束前至少24小时关闭自动续费，否则订阅将自动续费',
      'cancellationPolicy': '账户将在当前期间结束前24小时内收取续费费用，并确定续费费用',
      'userAgreement': '用户协议',
      'privacyPolicy': '隐私政策',
      'membershipBeginnerMining': '初级挖矿',
      'membershipSubscribe': '订阅',
      'privacyAgreement': '隐私协议',
      'privacyAgreementContent':
          '我们尊重并保护您的隐私。使用我们的服务即表示您同意我们的隐私政策和服务条款。我们将根据适用的法律法规收集和使用您的信息，为您提供更好的服务。',
      'agreeAndContinue': '同意并继续',
      'disagree': '不同意',
      'privacyPolicyText': '隐私政策',
      'termsOfServiceText': '服务条款',
      'mustAgreeToContinue': '您必须同意隐私政策才能继续使用应用',
      'personalInformation': '个人信息',
      'googleAccount': 'Google 账号',
      'appleAccount': 'Apple 账号',
      'tapToConnect': '点击连接',
      'unbindAccount': '解绑账号',
      'unbindConfirmMessage': '您确定要解绑此账号吗？',
      'unbindSuccess': '账号解绑成功',
      'cancel': '取消',
      'unbind': '解绑',
      'contractGuideTitle': '比特币挖矿合约',
      'contractGuideP1':
          '选择挖矿合约时，算力是关键指标。显示在右下角（如“2Gh/s”），算力越高，挖矿速度越快。因此提升算力是提升挖矿收益的首要目标。',
      'contractGuideP2':
          '付费合约包含“连续性加成”——对长期用户的额外奖励，叠加在日常收益之上。付费合约持续时间越长，加成倍数越高。例如 2 倍加成可使该合约收益翻倍。',
      'contractGuideP3':
          '请注意，最终收益受您在比特币网络中的算力占比影响，该占比会随全网矿工数量波动。日收益可能在 ±10% 范围内浮动，但长期收益趋于稳定平均值。',
      'contractGuideP4': '更长的挖矿周期通常意味着更大的整体收益增长空间。',
      'learnMore': '了解更多',
      'enterInvitationCode': '输入邀请码',
      'enterInvitationCodePlaceholder': '输入邀请码',
      'paste': '粘贴',
      'miningSpeedRewards': '挖矿速度奖励',
      'confirm': '确认',
    },
  };
}

class _AppLocalizationsDelegate
    extends LocalizationsDelegate<AppLocalizations> {
  const _AppLocalizationsDelegate();

  @override
  bool isSupported(Locale locale) {
    return ['en', 'zh'].contains(locale.languageCode);
  }

  @override
  Future<AppLocalizations> load(Locale locale) async {
    return AppLocalizations(locale);
  }

  @override
  bool shouldReload(_AppLocalizationsDelegate old) => false;
}
